package com.tenement.controller;

import com.tenement.common.Axios;
import com.tenement.entity.Alipay;
import com.tenement.enums.RespBusiness;
import com.tenement.service.AlipayService;
import com.tenement.vo.QueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 *  控制层。
 *
 * @author BertXie
 * @since 1.0.1
 */
@RestController
@RequestMapping("/alipay")
@RequiredArgsConstructor
@Api(tags = "支付宝配置管理")
public class AlipayController {

    private final AlipayService alipayService;

    @ApiOperation("操作支付宝配置")
    @PutMapping("operator")
    public Axios operator(@RequestBody Alipay alipay) {
        return alipayService.saveOrUpdate(alipay) ? Axios.success(RespBusiness.SUCCESS) : Axios.error(RespBusiness.FAIL);
    }


    @ApiOperation("查询支付宝配置")
    @PostMapping("list")
    public Axios list(@RequestBody QueryVo queryVo) {
        return Axios.success(alipayService.list(queryVo));
    }

}
